%% Author: zhangjun
%% Created: 2008-12-1
%% Description: TODO: Add description to recordtest
-module(recordtest).

%%-include("defines.hrl").
%%
%% Include files
%%

-record(state, {
	  all = true :: bool(),   % monitor all the sup restart info
	  sups = [] :: list(),     % the sups list
	  action = null           % do action
	 }).

-record(todo, {
	  who,
	  status,
	  text = true::bool()
	 }).

-record(redo, {
	  who,
	  status,
	  text = true::bool()
	 }).

%%
%% Exported Functions
%%
-export([start/0]).

%%
%% API Functions
%%

gene_except(Rec) ->
    %#todo{status=dead,text=Text} = Rec,
    erlang:error(rec),
    ok.

start(Record) when is_atom(Record)  -> 
    X = #Record{text="i am joe!"},
    X1 = X#Record{who=zhangjun,status=alive,text="i am zhangjun!"}, %update record element value
    #Record{status=Status, text=Text} = X1, %get record element 
    io:format("record is ~p~n~p~n", [X,X1]),
    io:format("X Status=~p, Text=~p~n",[X#Record.status,X#Record.text]),%get record element
    io:format("X1 Status=~p, Text=~p~n",[Status,Text]),
    %will drop exception%
    %
    
    try  
        begin
        #Record{status=dead,text=Text} = X1,
        ok
        end
	catch
        throw:E  ->  {caught, thrown, E};  
        exit:E    -> {caught, exited, E};
        error:E  ->  {caught, error, E, erlang:get_stacktrace()};
        _:E -> {caught, exception ,E}
    end.

%%
%% Local Functions
%%

